package com.sx.zongzhi.adapter;

import android.content.Context;
import android.view.View;
import android.widget.CheckBox;

import com.sx.zongzhi.R;
import com.sx.zongzhi.bean.GlobalBean;
import com.sx.zongzhi.bean.PublicBean;
import com.zhy.adapter.abslistview.CommonAdapter;
import com.zhy.adapter.abslistview.ViewHolder;

import java.util.List;

/**
 * Created by admin on 2017/12/16.
 */

public class HouseTypeAdapter  extends CommonAdapter<GlobalBean> {


    public HouseTypeAdapter(Context context, int layoutId, List<GlobalBean> datas) {
        super(context, layoutId, datas);
    }

    @Override
    protected void convert(ViewHolder viewHolder, final GlobalBean item, int position) {
        CheckBox checkBox=viewHolder.getView(R.id.checkbox);
        checkBox.setText(item.getDisplayName());
        checkBox.setChecked(item.isSelect());
        checkBox.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (mCallback != null) {
                    mCallback.getData(item);
                }
            }
        });

    }

    EventTypeCallback mCallback;
    /**
     * 定义一个接口
     */
    public interface EventTypeCallback {
        void getData(GlobalBean typesBean);
    }
    /*接口回调*/
    public void getEventType(EventTypeCallback callback) {
        mCallback = callback;
    }
}
